﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using ZhimeiSoft.Framework.Client.Utils;
using ZhimeiSoft.CharmManager.Client.Manager;

namespace ZhimeiSoft.CharmManager.Client.Forms
{
    public partial class ServiceItemSearch : UserControl
    {
        public delegate void EventFilterServiceItem(string sKeyword);
        public delegate void EventSearchKeywordChanged(string sKeyword);

        private DataSet dsServiceItem;

        public string Keyword
        {
            get { return textEdit.Text.Trim(); }
        }

        public bool ShowSearchButton
        {
            set { btnSearch.Visible = value; }
        }

        public ServiceItemSearch()
        {
            InitializeComponent();
        }

        public EventFilterServiceItem onFilterServiceItem;
        public EventSearchKeywordChanged onSearchKeyWordChanged;

        private void btnSearch_Click(object sender, EventArgs e)
        {
            string sKeyword = textEdit.Text.Trim();

            if (onSearchKeyWordChanged != null)
            {
                onSearchKeyWordChanged(sKeyword);
            }
        }

        private void textEdit_EditValueChanged(object sender, EventArgs e)
        {
            string sKeyWord = textEdit.Text.Trim();

            if (onFilterServiceItem != null)
            {
                onFilterServiceItem(sKeyWord);
            }

        }

        private void InitServiceItemData()
        {
            string error = string.Empty;
            string sFilter = "";
            bool bFlag = BussinessProxyManager.Instance.QueryServiceItem(sFilter, out dsServiceItem, out error);
            if (bFlag == false)
            {
                MsgBox.MsgInfo(error);
                return;
            }
        }

        private void textEdit_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                btnSearch_Click(null, null);
            }
        }

        
    }
}
